import React,{Component} from 'react'
import Child1 from './child1'
import Child2 from './child2'
import {Link,Route,Redirect} from 'react-router-dom'
class About extends Component{
	constructor(props){
		super(props);
		this.state = {
			myName : "这里是about页面"
		}
	}
	componentWillMount(){

	}
	showName(){
		console.log(this);
	}
	render(){
		let Child1Com = null;
		if(this.props.location.pathname=='/about'){
			Child1Com = <Redirect to="/about/child1">child1</Redirect>;
		}else{
				Child1Com = <Link to="/about/child1">child1</Link>;
		}
		return (
			<div>
				{this.state.myName}
				<div>
					<button onClick={this.showName.bind(this)}>按钮</button>
					<Link to="/inbox">inbox</Link>
						<div>
						{Child1Com}
						<Link to="/about/child2/4">child2</Link>
						 <Route path="/about/child1" component={Child1}/>
						 <Route path="/about/child2/:id" component={Child2}/>
						</div>
				</div>
			</div>
		)
	}
}
export default About
